package com.demo.pk.controller;

import java.util.List;

import javax.annotation.Resource;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.demo.pk.common.utils.DataResult;
import com.demo.pk.entity.PhoneAgentTaskTestEntity;
import com.demo.pk.service.PhoneAgentTaskTestService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;



/**
 * 日常录音品控
 *
 * @author WBB
 * @email *****@mail.com
 * @date 2021-07-25 19:07:32
 */
@RequestMapping("/phoneAgentTaskTest")
@RestController
@Api(tags = "日常录音品控")
public class PhoneAgentTaskTestController {
    @Resource
    private PhoneAgentTaskTestService phoneAgentTaskTestService;

    @ApiOperation(value = "新增")
    @PostMapping("/add")
    @RequiresPermissions("phoneAgentTaskTest:add")
    @ResponseBody
    public DataResult add(@RequestBody PhoneAgentTaskTestEntity phoneAgentTaskTest){
        phoneAgentTaskTestService.save(phoneAgentTaskTest);
        return DataResult.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("/delete")
    @RequiresPermissions("phoneAgentTaskTest:delete")
    @ResponseBody
    public DataResult delete(@RequestBody @ApiParam(value = "id集合") List<String> ids){
        phoneAgentTaskTestService.removeByIds(ids);
        return DataResult.success();
    }

    @ApiOperation(value = "更新")
    @PutMapping("/update")
    @RequiresPermissions("phoneAgentTaskTest:update")
    @ResponseBody
    public DataResult update(@RequestBody PhoneAgentTaskTestEntity phoneAgentTaskTest){
        phoneAgentTaskTestService.updateById(phoneAgentTaskTest);
        return DataResult.success();
    }

    @ApiOperation(value = "查询分页数据")
    @PostMapping("/listByPage")
    @RequiresPermissions("phoneAgentTaskTest:list")
    @ResponseBody
    public DataResult findListByPage(@RequestBody PhoneAgentTaskTestEntity phoneAgentTaskTest){
        Page page = new Page(phoneAgentTaskTest.getPage(), phoneAgentTaskTest.getLimit());
        LambdaQueryWrapper<PhoneAgentTaskTestEntity> queryWrapper = Wrappers.lambdaQuery();
        //查询条件示例
        //queryWrapper.eq(PhoneAgentTaskTestEntity::getId, phoneAgentTaskTest.getId());
        IPage<PhoneAgentTaskTestEntity> iPage = phoneAgentTaskTestService.page(page, queryWrapper);
        return DataResult.success(iPage);
    }

}
